﻿(function () {
    return {
        setting: {
            id: "main_top"
        },
        setPos: function () {
            var a = $(window),
                d = a.width(),
                e = this.getScroll().top,
                b, c;
            if (d <= 1070) {
                b = d - $("#" + this.controlId).width();
                c = a.scrollTop() - e + a.height() - $("#" + this.controlId).height()
            } else {
                b = $("#" + this.setting.id).offset().left + $("#" + this.setting.id).width() + 3;
                c = a.scrollTop() - e + (a.height() - $("#" + this.controlId).height()) / 2
            }
            $("#" + this.controlId).css({
                left: b + "px",
                top: c + "px"
            });
            !this.fixed && this.setFixed()
        },
        getScroll: function () {
            var b = document.documentElement,
                a = document.body;
            return {
                left: Math.max(b.scrollLeft, a.scrollLeft),
                top: Math.max(b.scrollTop, a.scrollTop)
            }
        },
        setFixed: function () {
            this.fixed = true;
            var e = !-[1, ] && !window.XMLHttpRequest,
                a = document.getElementById(this.controlId).style;
            if (e && document.body.currentStyle.backgroundAttachment !== "fixed") {
                var b = document.getElementsByTagName("html")[0].style;
                b.backgroundImage = "url(about:blank)";
                b.backgroundAttachment = "fixed";
                a.position = "absolute";
                a.removeExpression("left");
                a.removeExpression("top");
                var d = "(document.documentElement || document.body)",
                    c = this.getScroll(),
                    f = parseInt(a.left) - c.left,
                    g = parseInt(a.top) - c.top;
                a.setExpression("left", "eval(" + d + ".scrollLeft + " + f + ') + "px"');
                a.setExpression("top", "eval(" + d + ".scrollTop + " + g + ') + "px"')
            } else a.position = "fixed"
        },
        bdsLoaded: function () {
            $("#" + this.controlId).show();
            this.setPos();
            var b = this,
                a;
            $(window).bind("resize", function () {
                a && clearTimeout(a);
                a = setTimeout(function () {
                    b.setPos()
                }, 200)
            })
        },
        init: function () {
            var b = this;
            b.controlId = "rightSider";
            var a = [];
            a.push('<div class="rightSider" style="display:none;" id="rightSider"><div class="scrollTop"><a href="#top" class="toTop" title="返回顶部"><span>返回顶部</span></a></div>');
            a.push('<div class="shareTitle">分享到</div>');
            a.push('<div class="share" style="width:40px;margin:0 auto;">');
            a.push('<div id="bdshare" class="bdshare_t bds_tools_32 get-codes-bdshare">');
            if ($.cookie("country") != null && $.cookie("country").indexOf("%u4E2D%u56FD") == -1) {
                a.push('<a class="bds_twi"></a><a class="bds_fbook"></a>');
            }
            else {
                a.push('<a class="bds_qzone"></a>');
                a.push('<a class="bds_renren"></a>');
            }
            a.push('<a class="bds_tsina"></a>');
            a.push('<a class="bds_tqq"></a>');
            a.push('<span class="bds_more">更多</span>');
            a.push("</div></div>");
            $("#" + b.setting.id).after(a.join(""));
            $.getScript("http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + (new Date).getHours(), function () {
                b.bdsLoaded()
            })
        }
    }
})().init();

if ($(window).width() > 1360) {
    document.write("<script type=\"text/javascript\">var cpro_id = \"u1243278\";</script><script src=\"http://cpro.baidustatic.com/cpro/ui/f.js\" type=\"text/javascript\"></script>");
}
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fbd9e04b23b4cabe600ae492a21a3241b' type='text/javascript'%3E%3C/script%3E"));